import axios from "axios";
import {reactive,onMounted,computed} from "vue";
export default function (){
let dogList=reactive([
    'https://images.dog.ceo/breeds/pembroke/n02113023_1151.jpg'

])
//axios发起请求
async function getDog(){
    try {
        let result = await axios.get('https://dog.ceo/api/breed/pembroke/images/random')
        // console.log(result.data)//Json格式链接信息
        // console.log(result.data.message)//只有链接
        dogList.push(result.data.message)//展示小狗
    }catch (error){
        alert("error")
    }
}
//挂载钩子
onMounted(()=>{
    getDog()//挂载的时候直接来一条狗
})
//外部提供数据
    return{dogList,getDog}
}